Skip to content

State machine exercises#20

Merged
alexoltean61 merged 8 commits into
alexoltean61:masterfrom
AndreiNet:state-machine-exercises
Jun 1, 2026
Merged

State machine exercises#20
alexoltean61 merged 8 commits into
alexoltean61:masterfrom
AndreiNet:state-machine-exercises

Conversation

@AndreiNet

Copy link
Copy Markdown
Contributor

No description provided.

Comment on lines +172 to +180
lemma executeLemma {μ st} (h1 : Reachable (.ok μ) st) (h2 : isFinal st) :
∃ fuel : ℕ, execute fuel μ = st := by
cases st with
| error => contradiction
| ok μx =>
obtain ⟨m, hm⟩ := @executeLemmaAux 0 _ _ h1
use m
rw [hm, execute]
simp [h2]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! You actually came up with a simpler proof than mine. For reference, the statement of the lemma I came up with was:

lemma executeLemmaAux {μ st} (h : Reachable (.ok μ) st) :
    (isFinal st → ∃ fuel : ℕ, execute fuel μ = st) ∧
    (∀ μ', st = (.ok μ') → ¬isFinal (.ok μ') →
      ∀ fuel' : ℕ, ∃ fuel : ℕ, execute fuel μ = execute fuel' μ' ) := by

Which is correct, but painful to state & prove. Yours is much cleaner, well done.

Comment thread SoftwareFoundations2/StackMachine/Lemmas.lean Outdated
Comment thread SoftwareFoundations2/StackMachine/Lemmas.lean Outdated
@alexoltean61 alexoltean61 force-pushed the solutions branch 2 times, most recently from 05e0e1e to e230428 Compare June 1, 2026 12:23
@alexoltean61 alexoltean61 changed the base branch from solutions to master June 1, 2026 12:25
@alexoltean61 alexoltean61 merged commit a7c1938 into alexoltean61:master Jun 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants